package com.pro.common.service.user.service.unit;

import java.math.BigDecimal;

import com.pro.common.api.service.ITestService;
import com.pro.common.service.user.service.UserAmountRecordService;
import com.pro.common.service.user.service.UserAmountService;
import com.pro.framework.api.enums.EnumAmountUpDown;

import com.pro.common.api.statics.user.amount.model.base.AmountEntityRecordBaseDTO;
import com.pro.common.api.statics.user.amount.model.base.AmountEntityUnitDTO;
import com.pro.common.api.user.model.db.UserAmount;
import com.pro.common.api.user.model.db.UserAmountRecord;
import com.pro.common.user.amount.config.storage.service.AmountEntityUnitService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Data
@Schema(description = "用户数额信息")
@Getter
@Service
public class UserAmountUnitService extends AmountEntityUnitService<UserAmount, UserAmountRecord, AmountEntityRecordBaseDTO> implements ITestService {
    @Autowired
    private final UserAmountService amountEntityService;
    @Autowired
    private final UserAmountRecordService amountEntityRecordService;

    @Override
    public void test() {
        change(new AmountEntityUnitDTO<>(List.of(
                AmountEntityRecordBaseDTO.builder()
                        .userId(0L)
                        .amountType("")
                        .upDown(EnumAmountUpDown.down)
                        .amount(new BigDecimal(0))
                        .recordType("")
                        .orderNo("")
                        .orderId(0L)
                        .orderUsername("")
                        .remark("")
                        .userRemark("")
                        .build()
        )));
    }
    @Override
    protected BigDecimal getMaxLimit(UserAmount entity) {
        return entity.getTotalAmount() == null ? BigDecimal.ZERO : entity.getTotalAmount();
    }
}
